import { BASIC_FLAG } from "$utils/enum";
import { getImg } from "$utils/imgs";
import dayjs from "dayjs";

export default {
  data() {
    return {
      basicFlag: BASIC_FLAG
    };
  },
  methods: {
    surplusTime(item) {
      const { startTime, planTime } = item
      // 当前时间
      const currentTime = dayjs().valueOf()
      const p = planTime * 60 * 1000
      const s = dayjs(startTime).valueOf() + p
      const seconds = dayjs(s).diff(currentTime, "seconds")
      const minutes = dayjs(s).diff(currentTime, "minutes")

      return {
        surplus: `${minutes}:${this.polishing(Math.abs(seconds % 60))}`,
        status: seconds >= 0
      }
    },
    polishing(number) {
      return number < 10 ? "0" + number : number
    },
    setImgUrl(item) {
      const url = getImg(item.selectBg)
      return url
    }

  }
};
